//
//  TableViewSectionHeaderView.m
//  FD
//
//  Created by Yasin on 2018/10/22.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "TableViewSectionHeaderView.h"
@interface TableViewSectionHeaderView()
/**2、灰色的线条*/
@property (nonatomic,  strong) UIView *grayLineView;

@end

@implementation TableViewSectionHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        
        
    }
    return self;
}

- (void)setupView {
    //设置颜色:不给颜色，默认都是透明的
    self.backgroundColor = [UIColor whiteColor];
    self.nameLb.backgroundColor = [UIColor whiteColor];

    [self addSubview:self.grayLineView];
    [self addSubview:self.nameLb];
}
- (void)layoutSubviews {
    [super layoutSubviews];

    [self.grayLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.height.mas_equalTo(1);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.width.mas_greaterThanOrEqualTo(100); //宽度自适应
        make.top.bottom.equalTo(self);
    }];
}




//getter
- (UIView *)grayLineView {
    if (!_grayLineView) {
        _grayLineView = [UIView new];
        _grayLineView.backgroundColor = rgba(170, 170, 170, 1.0); //灰色
    }
    return _grayLineView;
}

- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
        _nameLb.textAlignment = NSTextAlignmentCenter;
        _nameLb.numberOfLines = 0; //允许换行
    }
    return _nameLb;
}

@end
